--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 0df55bd6980e0195ae340153aa69efa476e6bc4d
Parents : 3dc7db5
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-06-06T20:25:32-05:00
feat(electron): add patch script for electron-installer-common to improve glob handling
Changes
2 files changed, 68 insertions(+), 1 deletions(-)
Diff
diff --git a/package.json b/package.json
index 7bfa1ee0..8378a3ee 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:install": "playwright install chromium",
- "electron-postinstall": "electron-builder install-app-deps && node scripts/ensure-micron-parser-package.js && node scripts/patch-electron-builder-fs.cjs",
+ "electron-postinstall": "electron-builder install-app-deps && node scripts/ensure-micron-parser-package.js && node scripts/patch-electron-builder-fs.cjs && node scripts/patch-electron-installer-common.cjs",
"electron": "pnpm run electron-postinstall && pnpm run build && electron .",
"dist": "pnpm run electron-postinstall && pnpm run build && electron-builder --publish=never",
"dist:linux": "pnpm run electron-postinstall && cross-env PLATFORM=linux pnpm run build && electron-builder --linux AppImage deb --publish=never",
diff --git a/scripts/patch-electron-installer-common.cjs b/scripts/patch-electron-installer-common.cjs
new file mode 100644
index 00000000..c5d36d26
--- /dev/null
+++ b/scripts/patch-electron-installer-common.cjs
@@ -0,0 +1,67 @@
+#!/usr/bin/env node
+
+const fs = require("node:fs");
+const path = require("node:path");
+
+const root = path.join(__dirname, "..");
+const nodeModules = path.join(root, "node_modules");
+
+const needle = "const glob = promisify(require('glob'))";
+const globShim = `const __ebGlobModule = require('glob')
+const glob = typeof __ebGlobModule === 'function'
+ ? promisify(__ebGlobModule)
+ : __ebGlobModule.glob.bind(__ebGlobModule)`;
+
+function patchGlobPromisify(source) {
+ if (!source.includes(needle) || source.includes("__ebGlobModule")) {
+ return source;
+ }
+ return source.replace(needle, globShim);
+}
+
+function walkJsFiles(dir, out = []) {
+ if (!fs.existsSync(dir)) {
+ return out;
+ }
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ if (entry.name === ".git") {
+ continue;
+ }
+ walkJsFiles(full, out);
+ continue;
+ }
+ if (entry.isFile() && entry.name.endsWith(".js")) {
+ out.push(full);
+ }
+ }
+ return out;
+}
+
+const targetRoots = [
+ path.join(nodeModules, "electron-installer-common"),
+ path.join(nodeModules, "@electron", "asar"),
+ path.join(nodeModules, "asar"),
+];
+
+let patched = 0;
+for (const targetRoot of targetRoots) {
+ for (const file of walkJsFiles(targetRoot)) {
+ const original = fs.readFileSync(file, "utf8");
+ if (!original.includes(needle)) {
+ continue;
+ }
+ const next = patchGlobPromisify(original);
+ if (next === original) {
+ continue;
+ }
+ fs.writeFileSync(file, next);
+ patched += 1;
+ console.log(`patched ${path.relative(root, file)}`);
+ }
+}
+
+if (patched === 0) {
+ console.log("electron-installer glob shim already applied or not needed");
+}
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────